import { createRootRoute, Outlet } from '@tanstack/react-router'
import { LayoutShell } from '@/components/layout/shell'
import { ThemeProvider } from '@/components/theme-provider'
import { AuthProvider, useAuth } from '@/providers/auth-provider'

function RootLayout() {
    return (
        <AuthProvider>
            <ThemeProvider>
                <RootContent />
            </ThemeProvider>
        </AuthProvider>
    )
}

function RootContent() {
    const { user } = useAuth()
    return (
        <LayoutShell
            user={user}
        >
            <Outlet />
        </LayoutShell>
    )
}

export const Route = createRootRoute({ component: RootLayout })